package it.magazzinoCofi.view;

import it.magazzinoCofi.controllers.UserLoginController;
import it.magazzinoCofi.model.DataUserModel;

import java.util.Observable;
import java.util.Observer;



public class PView implements Observer {
	
	private static PView Main; //SINGLETON
	
	BaseFrame JMain;
	//private DataUserModel m_model;

	public PView(BaseFrame Frame) {
		Main=this;
		
		/**
		 * SETUP iniziale Login
		 */
		UserLoginFrame login=new UserLoginFrame();
		DataUserModel model=new DataUserModel();
		UserLoginController controller=new UserLoginController(model, login);
		login.setVisible(true);
		
		JMain = login;
		//m_model = model;

	}

	public BaseFrame getFrame() {
		return JMain;
	}

	@Override
	public void update(Observable o, Object arg) {
		System.out.println("CHANGED");
		
		if((Integer)arg==1){
			JMain.setVisible(false);
			JMain=new SchermataPrincipale();
			System.out.println("creata principale");
			JMain.setVisible(true);
		}
			
		
		//JMain.revalidate();

	}
	
	public static synchronized PView getInstance() {
        if (Main == null) 
            Main = new PView(null);
        return Main;
    }
}
